package com.zhny.iot.sd.sfj.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.plugin.mqtt.MqttConfig;
import com.zhny.aiot.plugin.mqtt.MqttDeviceFactory;
import com.zhny.iot.sd.sfj.plugin.model.SDFertilizerStoreEntry;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.ArrayList;
import java.util.List;

public class SDFertilizerPlugin extends Plugin {
    public SDFertilizerPlugin(PluginWrapper wrapper) {
        super (wrapper);
    }
    @Extension
    public static class SDFertilizerFactory extends MqttDeviceFactory<SDConfig> {


        @Override
        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new SDFertilizerDevice (this,iCenterFacilities,entity);
        }

        @Override
        public Class<SDConfig> configClass() {
            return SDConfig.class;
        }

        @Override
        public List<CommandEntry> supportCommandClasses(){
            List<CommandEntry> commands = new ArrayList<> ();
            commands.add(CommandEntry.valueOf("openPump", "打开水泵", "无参数",null));
            commands.add(CommandEntry.valueOf("closePump", "关闭水泵", "无参数",null));
            commands.add(CommandEntry.valueOf("openFert", "打开吸肥泵", "无参数",null));
            commands.add(CommandEntry.valueOf("closeFert", "关闭吸肥泵", "无参数",null));
            return commands;
        }

        @Override
        public Class<? extends StoreEntity> storeClass() {
            return SDFertilizerStoreEntry.class;
        }

        @Override
        public String getId() {
            return "sd-sfj-plugin";
        }

        @Override
        public String getName() {
            return "圣大水肥一体机";
        }

        @Override
        public FactoryType getType() {
            return FactoryType.FertilizerController;
        }
    }
}
